﻿Option Explicit On
Option Strict On

Imports System.Reflection
Imports LogginsLogDSTableAdapters
Imports System.Data

Partial Class private_secure_members_manage_MyLists
    Inherits System.Web.UI.Page
    Dim PubTempTable As Data.DataTable
    Dim u As MembershipUser

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        u = Membership.GetUser(HttpContext.Current.User.Identity.Name)

        If Not Page.IsPostBack Then
            If Not Session("EntityID") Is Nothing Then
                DropDownList1.SelectedValue = CStr(Session("EntityID"))
            End If

        End If



        Try
            If Not Request.QueryString("u") Is Nothing Then
                DropDownList1.SelectedValue = Request.QueryString("u").ToString()
            End If
            If Not Page.IsPostBack Then
                'DropDownList1.Items.Insert(0, New ListItem("Select item from list", [String].Empty))EntityID
            End If
            'GridView1.DataBind()
        Catch ex As Exception

        End Try
    End Sub

    Protected Sub MyEntityODS_Selecting(sender As Object, e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles MyEntityODS.Selecting
        e.InputParameters("UserId") = u.ProviderUserKey
    End Sub

    'Protected Sub Button3_Click(sender As Object, e As System.EventArgs) Handles Button3.Click
    '    'If any of the items have been checked do the following
    '    ' Collect them into a comma separated value and pass it into the proc dbo.usp_TargetListSaveColumnList @TargetListId, @ColumnList like this
    '    ' ALTER PROCEDURE dbo.usp_TargetListSaveColumnList @TargetListId INT, @ColumnList NVARCHAR(1024)
    '    'Dim targetlistcolumnlistTA As New LogginsLogDSTableAdapters.usp_TargetListColumnListSelectTableAdapter()
    '    'Dim targetlistcolumnlistDT As New LogginsLogDS.usp_TargetListColumnListSelectDataTable
    '    'targetlistcolumnlistDT = targetlistcolumnlistTA.GetData(Nothing)
    '    'Dim lkptargetlistcolumnlistTA As New LogginsLogDSTableAdapters.usp_lkp_TargetListColumnListTableAdapter()
    '    'Dim lkptargetlistcolumnlistDT As New LogginsLogDS.usp_lkp_TargetListColumnListDataTable
    '    'lkptargetlistcolumnlistDT = lkptargetlistcolumnlistTA.GetData(Nothing)

    '    'Dim targetlist = From tl In targetlistcolumnlistDT.AsEnumerable() Where tl.TargetListId = CInt(GridView1.SelectedValue.ToString()) Select tl
    '    'Dim targetlistid = (targetlist).FirstOrDefault()
    '    'For Each targetlistRow As LogginsLogDS.usp_TargetListColumnListSelectRow In targetlistcolumnlistDT
    '    '    lkptargetlistcolumnlistTA.Delete(targetlistRow.ColumnId)
    '    'Next
    '    'targetlistcolumnlistTA.Delete((targetlist).FirstOrDefault().Id)
    '    Dim delall As New LogginsLogDSTableAdapters.SPTableAdapter()
    '    delall.usp_TargetListColumnListDeleteByTargetListId(CInt(GridView1.SelectedValue.ToString()))
    '    Dim parameterstring As String = String.Empty
    '    For Each row As GridViewRow In grdSelectedFields.Rows
    '        ' Access the CheckBox
    '        Dim columnname As String = grdSelectedFields.DataKeys(row.RowIndex).Value.ToString()
    '        Dim cb As CheckBox = CType(row.FindControl("chkboxFilled"), CheckBox)
    '        If cb IsNot Nothing AndAlso cb.Checked Then
    '            parameterstring += "," + cb.Text
    '            ''Dim newlkp As Integer = lkptargetlistcolumnlistTA.usp_lkp_TargetListColumnListInsert(cb.Text, True)
    '            'targetlistcolumnlistTA.Insert(DropDownList1.SelectedValue, newlkp, True)
    '        End If
    '    Next
    '    parameterstring = parameterstring.Remove(0, 1)

    '    If Not GridView1.SelectedValue Is Nothing Then
    '        Dim savecolumnsTA As New LogginsLogDSTableAdapters.SPTableAdapter()
    '        savecolumnsTA.usp_TargetListSaveColumnList(CType(GridView1.SelectedValue, Integer?), parameterstring)
    '    Else
    '        Label3.Text = "Please select list from grid first"

    '    End If

    '    Dim x = parameterstring

    'End Sub


    Protected Sub GridView1_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand

        If e.CommandName = "NewList" Then
            'Dim selectedID As Integer = CInt(e.CommandArgument.ToString())
            txtName.Text = ""
            txtNote.Text = ""

            btnInsert.Visible = True
            btnUpdate.Visible = False
            'hdfSelectedId.Value = CStr(selectedID)
            If CDbl(DropDownList1.SelectedValue) = 0 Then
                Label6.Text = "ERROR"
                Label7.Text = "Please select item from dropdown list"

                ModalPopupExtender2.Show()
            Else
                InsertPopupExtender.Show()
            End If

        ElseIf e.CommandName = "CustomEdit" Then
            Dim selectedID As Integer = CInt(e.CommandArgument.ToString())

            'Dim selectedID As Integer = CInt(e.CommandArgument.ToString())
            Dim targetlistTA As New LogginsLogDSTableAdapters.usp_TargetListByIDTableAdapter()
            Dim targetlistDT As LogginsLogDS.usp_TargetListByIDDataTable
            targetlistDT = targetlistTA.GetData(selectedID)
            For Each targetlistRow As LogginsLogDS.usp_TargetListByIDRow In targetlistDT
                txtName.Text = targetlistRow.Name
                'ddllkpListType.SelectedValue = CStr(targetlistRow.ListTypeId)
                txtNote.Text = targetlistRow.Note
                hdfSelectedId.Value = CStr(selectedID)
            Next
            btnInsert.Visible = False
            btnUpdate.Visible = True
            If CDbl(DropDownList1.SelectedValue) = 0 Then
                Label6.Text = "ERROR"
                Label7.Text = "Please select item from dropdown list"

                ModalPopupExtender2.Show()
            Else
                InsertPopupExtender.Show()
            End If
        ElseIf e.CommandName = "PopulateList" Then
            Dim selectedID As Integer = CInt(e.CommandArgument.ToString())
            Session.Add("eid", CType(DropDownList1.SelectedValue, Double))
            Session.Add("lid", selectedID)
            Response.Redirect("~/private/secure_members/manage/MyRecipients.aspx?eid=" & CType(DropDownList1.SelectedValue, Double) & "&lid=" & selectedID & "&u=" & CType(DropDownList1.SelectedValue, Double))

        ElseIf e.CommandName = "Edit" Then

            Button2.Enabled = False
        ElseIf e.CommandName = "Cancel" Then

            Button2.Enabled = True

        ElseIf e.CommandName = "Update" Then

            Button2.Enabled = True

        End If


    End Sub
    Protected Sub btnUpdate_Click(sender As Object, e As System.EventArgs) Handles btnUpdate.Click
        If txtName.Text = "" Then
            lblInfo.Text = "Please enter the Name of the list"
        Else
            Dim targetlistTA As New LogginsLogDSTableAdapters.usp_TargetListByIDTableAdapter()
            Dim targetlistDT As LogginsLogDS.usp_TargetListByIDDataTable
            targetlistDT = targetlistTA.GetData(CType(hdfSelectedId.Value, Integer?))
            For Each targetlistRow As LogginsLogDS.usp_TargetListByIDRow In targetlistDT
                Dim msgref As String
                Dim billingref As String
                Dim datecreated As Date
                If targetlistRow.IsMsgRefNull Then
                    msgref = Nothing
                Else
                    msgref = targetlistRow.MsgRef
                End If
                If targetlistRow.IsBillingRefNull Then
                    billingref = Nothing
                Else
                    billingref = targetlistRow.MsgRef
                End If
                If targetlistRow.IsDateCreatedNull Then
                    datecreated = Nothing
                Else
                    datecreated = targetlistRow.DateCreated
                End If
                'CType(ddllkpListType.SelectedValue, Byte?), txtNote.Text, targetlistRow.SingleUse, targetlistRow.DateCreated, _
                targetlistTA.Update(CType(hdfSelectedId.Value, Integer?), targetlistRow.EntityId, txtName.Text, msgref, billingref, _
                                    3, txtNote.Text, targetlistRow.SingleUse, datecreated, True, _
                                     targetlistRow.DateDiscarded, True)
            Next
            GridView1.DataBind()

            InsertPopupExtender.Hide()
            'Response.Redirect("~/private/secure_members/manage/Mytargetlist.aspx?u=" & DropDownList1.SelectedValue)
        End If
        'pnlSelectedColumns.Visible = False

    End Sub

    Protected Sub btnInsert_Click(sender As Object, e As System.EventArgs) Handles btnInsert.Click
        'InsertTargetListODS.Insert()
        Dim rnum As Integer = 0
        Dim insertTargetList As New usp_TargetListTableAdapter()
        'insertTargetList.Insert(CType(DropDownList1.SelectedValue, Integer?), txtName.Text, String.Empty, String.Empty, CType(ddllkpListType.SelectedValue, Byte?), txtNote.Text, True, Date.Today, True, True, True, CType(rnum, Int32?))
        insertTargetList.Insert(CType(DropDownList1.SelectedValue, Integer?), txtName.Text, String.Empty, String.Empty, 3, txtNote.Text, True, Date.Today, True, True, True, CType(rnum, Int32?))
        Dim rr As Integer = 0
        rr = rnum
        GridView1.DataBind()
        InsertPopupExtender.Hide()

        'e.InputParameters("EntityId") = CType(DropDownList1.SelectedValue, Integer?)
        'e.InputParameters("Name") = txtName.Text
        'e.InputParameters("MsgRef") = String.Empty
        'e.InputParameters("BillingRef") = String.Empty
        'e.InputParameters("ListTypeId") = CType(ddllkpListType.SelectedValue, Byte?)
        'e.InputParameters("Note") = txtNote.Text
        'e.InputParameters("SingleUse") = True
        'e.InputParameters("DateCreated") = DateTime.Now
        'e.InputParameters("IsDefault") = True
        'e.InputParameters("AutoDiscarded") = True
        'e.InputParameters("DateDiscarded") = True
        'e.InputParameters("Active") = True

        'If txtName.Text = "" Then
        '    lblInfo.Text = "Please enter the Name of the list"
        'Else
        '    Dim justinsertedid As Integer
        '    Dim targetlistTA As New LogginsLogDSTableAdapters.usp_TargetListTableAdapter()
        '    targetlistTA.Insert(CType(DropDownList1.SelectedValue, Integer?), txtName.Text, Nothing, Nothing, CType(ddllkpListType.SelectedValue, Byte?), _
        '                        txtNote.Text, True, DateTime.Now, True, True, True, CType(justinsertedid, Integer?))
        '    GridView1.DataBind()
        '    Response.Redirect("~/private/secure_members/manage/Mytargetlist.aspx?u=" & justinsertedid)
        'End If
        'pnlSelectedColumns.Visible = False

    End Sub
    'Protected Sub lkpListTypeODS_Selecting(sender As Object, e As System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs) Handles lkpListTypeODS.Selecting
    '    e.InputParameters("Id") = Nothing
    'End Sub



    'Protected Sub grdSelectedFields_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grdSelectedFields.RowCommand
    '    If e.CommandName = "GetSelected" Then
    '        Dim parameterstring As String = String.Empty
    '        For Each row As GridViewRow In grdSelectedFields.Rows
    '            ' Access the CheckBox
    '            Dim columnname As String = grdSelectedFields.DataKeys(row.RowIndex).Value.ToString()
    '            Dim cb As CheckBox = CType(row.FindControl("chkFilled"), CheckBox)
    '            If cb IsNot Nothing AndAlso cb.Checked Then
    '                parameterstring += "," + cb.Text
    '                ''Dim newlkp As Integer = lkptargetlistcolumnlistTA.usp_lkp_TargetListColumnListInsert(cb.Text, True)
    '                'targetlistcolumnlistTA.Insert(DropDownList1.SelectedValue, newlkp, True)
    '            End If

    '        Next

    '        Dim x = parameterstring
    '    End If

    'End Sub

    Protected Sub InsertTargetListODS_Inserting(sender As Object, e As System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs) Handles InsertTargetListODS.Inserting

        e.InputParameters("EntityId") = CType(DropDownList1.SelectedValue, Integer?)
        e.InputParameters("Name") = txtName.Text
        e.InputParameters("MsgRef") = String.Empty
        e.InputParameters("BillingRef") = String.Empty
        e.InputParameters("ListTypeId") = 3
        e.InputParameters("Note") = txtNote.Text
        e.InputParameters("SingleUse") = True
        e.InputParameters("DateCreated") = DateTime.Today
        e.InputParameters("IsDefault") = True
        e.InputParameters("AutoDiscarded") = True
        e.InputParameters("DateDiscarded") = True
        e.InputParameters("Active") = True
        GridView1.DataBind()
        ' UpdatePanel1.Update()TargetListId, 
    End Sub

    Protected Sub InsertTargetListODS_Inserted(sender As Object, e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs) Handles InsertTargetListODS.Inserted
        Dim justinsertedid As Integer
        If Not e.OutputParameters("TargetListId") Is Nothing Then
            justinsertedid = CInt(e.OutputParameters("TargetListId"))

        End If

        'Response.Redirect("~/private/secure_members/manage/Mytargetlist.aspx?u=" & DropDownList1.SelectedValue)
        ' DropDownList1.DataBind()
        GridView1.DataBind()
        InsertPopupExtender.Hide()


    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        '        Dim isreadonly As PropertyInfo =
        'GetType(System.Collections.Specialized.NameValueCollection).GetProperty( _
        '"IsReadOnly", BindingFlags.Instance Or BindingFlags.NonPublic)

        '        ' make collection editable
        '        isreadonly.SetValue(Me.Request.QueryString, False, Nothing)
        '        If Not Request.QueryString("u") Is Nothing Then
        '            Request.QueryString.Remove("u")
        '        End If
        If CInt(DropDownList1.SelectedValue) = 0 Then
            Session.Remove("EntityID")
        Else
            Session("EntityID") = DropDownList1.SelectedValue
        End If

        pnlSelectedColumns.Visible = False
        GridView1.Visible = True

    End Sub

    Protected Sub btnCancel_Click(sender As Object, e As System.EventArgs) Handles btnCancel.Click
        InsertPopupExtender.Hide()
    End Sub

    'Protected Sub CheckBoxList1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles CheckBoxList1.SelectedIndexChanged
    '    Dim si = CheckBoxList1.SelectedIndex
    '    Dim sv = CheckBoxList1.SelectedValue
    '    Dim dvf = CheckBoxList1.DataValueField
    '    Dim dtf = CheckBoxList1.DataTextField
    '    Dim sel = CheckBoxList1.Items.Item(si)
    '    If sel.Selected Then
    '        Dim insertcolumnTA As New LogginsLogDSTableAdapters.SPTableAdapter()
    '        insertcolumnTA.usp_TargetListSaveColumnList(CType(GridView1.SelectedValue, Integer?), dtf)
    '    Else

    '    End If

    'End Sub

    Protected Sub btnInsertCol_Click(sender As Object, e As System.EventArgs) Handles btnInsertCol.Click


        Dim parameterstring As String = String.Empty
        For Each row As GridViewRow In grdSelectedFields.Rows
            ' Access the CheckBox
            Dim columnname As String = grdSelectedFields.DataKeys(row.RowIndex).Value.ToString()
            Dim cb As CheckBox = CType(row.FindControl("chkboxFilled"), CheckBox)
            If cb IsNot Nothing AndAlso cb.Checked Then
                parameterstring += "," + cb.Text
                ''Dim newlkp As Integer = lkptargetlistcolumnlistTA.usp_lkp_TargetListColumnListInsert(cb.Text, True)
                'targetlistcolumnlistTA.Insert(DropDownList1.SelectedValue, newlkp, True)
            End If
        Next


        If Not GridView1.SelectedValue Is Nothing Then
            If parameterstring.Count > 1 Then
                Dim delall As New LogginsLogDSTableAdapters.SPTableAdapter()
                delall.usp_TargetListColumnListDeleteByTargetListId(CInt(GridView1.SelectedValue.ToString()))

                Dim savecolumnsTA As New LogginsLogDSTableAdapters.SPTableAdapter()
                savecolumnsTA.usp_TargetListSaveColumnList(CType(GridView1.SelectedValue, Integer?), parameterstring.Replace(" ", "").Remove(0, 1))

            Else
                Label3.Text = "Please select at least one column."

            End If

        Else
            Label3.Text = "Please first select an item from the grid"

        End If
        'pnlSelectedColumns.Visible = False

    End Sub

    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        'pnlSelectedColumns.Visible = True
        Dim x = GridView1.SelectedValue
        Label8.Text = CStr(GridView1.SelectedValue)
        grdSelectedFields.DataBind()
        pnlSelectedColumns.Visible = True
        ModalPopupExtender1.Show()

    End Sub

    Protected Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
        txtName.Text = ""
        txtNote.Text = ""

        btnInsert.Visible = True
        btnUpdate.Visible = False
        'hdfSelectedId.Value = CStr(selectedID)
        If CDbl(DropDownList1.SelectedValue) = 0 Then
            Label6.Text = "ERROR"
            Label7.Text = "Please select item from dropdown list"

            ModalPopupExtender2.Show()
        Else
            InsertPopupExtender.Show()
        End If
    End Sub

    Protected Sub GridView1_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        Dim newname As String
        Dim newnote As String
        Dim newlisttype As Byte
        Dim ID As Integer = CInt(GridView1.DataKeys(e.RowIndex).Value.ToString())
        Dim te = e.NewValues("ListTypeId")
        If e.NewValues("Name") Is Nothing Then
            newname = Nothing
        Else
            newname = e.NewValues("Name").ToString()
        End If
        If e.NewValues("Note") Is Nothing Then
            newnote = Nothing
        Else
            newnote = e.NewValues("Note").ToString()
        End If
        If e.NewValues("ListTypeId") Is Nothing Then
            newlisttype = 3
        Else
            newlisttype = 3
        End If
        Dim eid As Integer
        Dim SingleUse As Boolean
        'Dim AutoDiscarded As Boolean
        Dim DateDiscarded As Boolean
        Dim msgref As String = ""
        Dim billingref As String = ""
        Dim datecreated As Date

        Dim targetlistTA As New LogginsLogDSTableAdapters.usp_TargetListByIDTableAdapter()
        Dim targetlistDT As LogginsLogDS.usp_TargetListByIDDataTable
        targetlistDT = targetlistTA.GetData(ID)
        For Each targetlistRow As LogginsLogDS.usp_TargetListByIDRow In targetlistDT
            If targetlistRow.IsMsgRefNull Then
                msgref = Nothing
            Else
                msgref = targetlistRow.MsgRef
            End If
            If targetlistRow.IsBillingRefNull Then
                billingref = Nothing
            Else
                billingref = targetlistRow.MsgRef
            End If
            If targetlistRow.IsDateCreatedNull Then
                datecreated = Nothing
            Else
                datecreated = targetlistRow.DateCreated
            End If
            eid = targetlistRow.EntityId

            'targetlistTA.Update(ID, targetlistRow.EntityId, newname, msgref, billingref, _
            '                    CType(newlisttype, Byte?), newnote, targetlistRow.SingleUse, Nothing, _
            '                    targetlistRow.AutoDiscarded, targetlistRow.DateDiscarded, True)

        Next
        If Not newname = String.Empty Then
            Dim targetlistnewTA As New LogginsLogDSTableAdapters.usp_TargetListByIDTableAdapter()
            'targetlistnewTA.Update(ID, eid, newname, msgref, billingref, CType(newlisttype, Byte?), newnote, SingleUse, Nothing, True, AutoDiscarded, DateDiscarded, True)
            targetlistnewTA.Update(ID, eid, newname, msgref, billingref, CType(newlisttype, Byte?), newnote, SingleUse, datecreated, True, DateDiscarded, True)
        Else
            Label7.Text = "Name must be filled."
            ModalPopupExtender2.Show()
        End If


    End Sub


    Protected Sub GridView1_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
        Try
            Dim ID As Integer = CInt(GridView1.DataKeys(e.RowIndex).Value.ToString())
            Dim targetlistnewTA As New LogginsLogDSTableAdapters.usp_TargetListByIDTableAdapter()

            Dim targetlistexpTA As New LogginsLogDSTableAdapters.usp_TargetListRecipient_ExpTableAdapter()
            Dim targetlistexpDT As LogginsLogDS.usp_TargetListRecipient_ExpDataTable

            targetlistexpDT = targetlistexpTA.GetData(Nothing)

            Dim deltargetlistexp = From delids In targetlistexpDT.AsEnumerable() Where delids.TargetListId = ID Select delids

            For Each delRow As LogginsLogDS.usp_TargetListRecipient_ExpRow In deltargetlistexp

                Dim targetlistexpdelTA As New LogginsLogDSTableAdapters.usp_TargetListRecipient_ExpTableAdapter()
                Dim rec_deleteTA As New LogginsLogDSTableAdapters.usp_RecipientSelectByTargetListIdTableAdapter()
                targetlistexpdelTA.Delete(delRow.Id)
                rec_deleteTA.Delete(delRow.RecipientId)
            Next

            targetlistnewTA.Delete(ID)

        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Protected Sub ObjectDataSource1_Inserted(sender As Object, e As ObjectDataSourceStatusEventArgs) Handles ObjectDataSource1.Inserted

    End Sub

    Protected Sub ObjectDataSource1_Inserting(sender As Object, e As ObjectDataSourceMethodEventArgs) Handles ObjectDataSource1.Inserting

    End Sub

    Protected Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        Response.Redirect("~/private/default.aspx")
    End Sub

    Protected Sub grdSelectedFields_DataBound(sender As Object, e As EventArgs) Handles grdSelectedFields.DataBound
        For Each row As GridViewRow In grdSelectedFields.Rows
            ' Access the CheckBox
            Dim columnname As String = grdSelectedFields.DataKeys(row.RowIndex).Value.ToString()
            Dim cb As CheckBox = CType(row.FindControl("chkboxFilled"), CheckBox)
            If cb IsNot Nothing Then
                If cb.Text = "FirstName" Then
                    cb.Text = "First Name"
                ElseIf cb.Text = "HomeEmailAddress" Then
                    cb.Text = "Home Email Address"
                ElseIf cb.Text = "WorkEmailAddress" Then
                    cb.Text = "Work Email Address"
                ElseIf cb.Text = "MobileNo" Then
                    cb.Text = "Mobile No"
                ElseIf cb.Text = "LastName" Then
                    cb.Text = "Last Name"
                ElseIf cb.Text = "DateAddedToList" Then
                    cb.Text = "Date Added To List"
                ElseIf cb.Text = "IsAdult" Then
                    cb.Text = "Is Adult"
                ElseIf cb.Text = "NI_Number" Then
                    cb.Text = "NI Number"
                ElseIf cb.Text = "SS_Number" Then
                    cb.Text = "SS Number"
                ElseIf cb.Text = "BirthMonth" Then
                    cb.Text = "Birth Month"
                ElseIf cb.Text = "BirthDay" Then
                    cb.Text = "Birth Day"
                ElseIf cb.Text = "BirthYear" Then
                    cb.Text = "Birth Year"
                ElseIf cb.Text = "PostCode" Then
                    cb.Text = "Post Code"
                ElseIf cb.Text = "HouseNo" Then
                    cb.Text = "House No"
                ElseIf cb.Text = "OccupationNote" Then
                    cb.Text = "Occupation Note"
                ElseIf cb.Text = "IsLocal" Then
                    cb.Text = "Is Local"
                End If

                'parameterstring += "," + cb.Text
                ''Dim newlkp As Integer = lkptargetlistcolumnlistTA.usp_lkp_TargetListColumnListInsert(cb.Text, True)
                'targetlistcolumnlistTA.Insert(DropDownList1.SelectedValue, newlkp, True)
            End If
        Next
    End Sub

    Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound
        If e.Row.RowType = DataControlRowType.DataRow Then


            Dim drv As DataRowView = DirectCast(e.Row.DataItem, DataRowView)

            For i As Integer = 0 To drv.DataView.Table.Columns.Count - 1

                e.Row.Cells(11).BackColor = System.Drawing.Color.FromArgb(172, 209, 233)
                e.Row.Cells(12).BackColor = System.Drawing.Color.FromArgb(172, 209, 233)
                e.Row.Cells(13).BackColor = System.Drawing.Color.FromArgb(172, 209, 233)

            Next
        End If
    End Sub
End Class
